package com.xingchi.tornado.dict.event;

import com.xingchi.tornado.core.enums.OperateTypeEnum;
import com.xingchi.tornado.dict.service.DictStorageService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;

/**
 * 字典数据变更事件监听器
 *
 * @author xiaoya
 * @date 2025/7/3 11:46
 */
@Slf4j
@Component
@RequiredArgsConstructor
public class DictDataChangeListener implements ApplicationListener<DictDataChangeEvent> {

    private final DictStorageService dictStorageService;

    @Override
    public void onApplicationEvent(DictDataChangeEvent event) {
        OperateTypeEnum operateType = event.getOperateType();
        String groupCode = event.getGroupCode();
        dictStorageService.dictChangeHandler(groupCode, operateType);
    }

}
